
<p id="notice"><%= flash[:notice] %></p>

<div class="intro-cartasur">
  <h3><%= t 'cartasur.forums.forumtitle' %>: <%= @forum.name %></h3>
  <p><%=  @forum.description %></p>
</div>
<br />
<table id="forums">
  <tr>
    <th width="60%"><%= t 'cartasur.forums.topictitle' %></th>
    <th width="10%"><%= t 'cartasur.forums.posts.noofposts' %></th>
    <th width="30%"><%= t 'cartasur.forums.lastpost' %></th>
  </tr>
  <% if @forum.topics.blank? %>
      <tr>
        <td colspan="3">
           <%=  t 'cartasur.forums.notopics' %>
        </td>
      </tr>
  <% else %>
      <% for topic in @forum.topics %>
          <tr>
            <td><%= link_to h(topic.name), cartasur_forum_topic_path(@forum,topic) %>
            <td><%= (topic.posts.try(:size)).to_s %></td>
            <td class="right">
                <% if @forum.most_recent_post %>
                    <%= distance_of_time_in_words_to_now @forum.most_recent_post.last_post_at %> ago<% else %>no posts
                <% end %>
            </td>
            <td><%= link_to (t 'cartasur.forums.show'), cartasur_forum_topic_url(@forum,topic) %></td>
            <% if admin_or_owner?(@user.id) %>
                <td><%=  (button_to (t 'cartasur.forums.destroy'), cartasur_forum_topic_path(@forum, topic), :confirm => (t 'cartasur.forums.areyousure'), :method => :delete) %></td>
             <% end %>
          </tr>
      <% end %>
  <% end %>
</table>

<br />
<p>
<% if admin? %>
    <%= link_to (t 'cartasur.forums.newtopic'), new_cartasur_forum_topic_path(@forum) %>  <br />
<% end %>
  <%= link_to (t 'cartasur.forums.backtoforums'), cartasur_forums_path   %>
</p>